﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LimitatorInterfaces;
using LimitatorInterfaces.CorrectServices;

namespace CorrectServices
{
    internal class GoLimitCorrector: ILimitCorrector
    {
        public bool Correct(LimitEntity sourceLimit, CorrectionLimitEntity correction)
        {
            if (sourceLimit == null) throw new ArgumentNullException("sourceLimit");
            if (correction == null) throw new ArgumentNullException("correction");

            if (sourceLimit.ClientCode != correction.ClientCode)
                throw new LimitCorrectorException("Коды клиентов в коррекции и исходном лимите не совпадают");


            sourceLimit.SetValue(sourceLimit.Value + correction.Value);
            correction.SetApplied();

            return true;
        }
    }
}


